<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>gnome-triggers</title>
<meta name="generator" content="DocBook XSL Stylesheets V1.76.1">
<link rel="home" href="index.html" title="GNOME Library Reference Manual">
<link rel="up" href="ch04.html" title="Miscellaneous">
<link rel="prev" href="libgnome-gnome-sound.html" title="gnome-sound">
<link rel="next" href="ch05.html" title="Lower Level Interactions">
<meta name="generator" content="GTK-Doc V1.16 (XML mode)">
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2">
<tr valign="middle">
<td><a accesskey="p" href="libgnome-gnome-sound.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td>
<td><a accesskey="u" href="ch04.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td>
<td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td>
<th width="100%" align="center">GNOME Library Reference Manual</th>
<td><a accesskey="n" href="ch05.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
</tr>
<tr><td colspan="5" class="shortcuts">
<a href="#libgnome-gnome-triggers.synopsis" class="shortcut">Top</a>
                   | 
                  <a href="#libgnome-gnome-triggers.description" class="shortcut">Description</a>
</td></tr>
</table>
<div class="refentry">
<a name="libgnome-gnome-triggers"></a><div class="titlepage"></div>
<div class="refnamediv"><table width="100%"><tr>
<td valign="top">
<h2><span class="refentrytitle"><a name="libgnome-gnome-triggers.top_of_page"></a>gnome-triggers</span></h2>
<p>gnome-triggers — Hierarchical signal mechanism for GNOME events.</p>
</td>
<td valign="top" align="right"></td>
</tr></table></div>
<div class="refsynopsisdiv">
<a name="libgnome-gnome-triggers.synopsis"></a><h2>Synopsis</h2>
<pre class="synopsis">
#include &lt;libgnome/libgnome.h&gt;

enum                <a class="link" href="libgnome-gnome-triggers.html#GnomeTriggerType" title="enum GnomeTriggerType">GnomeTriggerType</a>;
<span class="returnvalue">void</span>                (<a class="link" href="libgnome-gnome-triggers.html#GnomeTriggerActionFunction" title="GnomeTriggerActionFunction ()">*GnomeTriggerActionFunction</a>)       (<em class="parameter"><code><span class="type">char</span> *msg</code></em>,
                                                         <em class="parameter"><code><span class="type">char</span> *level</code></em>,
                                                         <em class="parameter"><code><span class="type">char</span> *supinfo[]</code></em>);
                    <a class="link" href="libgnome-gnome-triggers.html#GnomeTrigger" title="GnomeTrigger">GnomeTrigger</a>;
<span class="returnvalue">void</span>                <a class="link" href="libgnome-gnome-triggers.html#gnome-triggers-add-trigger" title="gnome_triggers_add_trigger ()">gnome_triggers_add_trigger</a>          (<em class="parameter"><code><a class="link" href="libgnome-gnome-triggers.html#GnomeTrigger" title="GnomeTrigger"><span class="type">GnomeTrigger</span></a> *nt</code></em>,
                                                         <em class="parameter"><code>...</code></em>);
<span class="returnvalue">void</span>                <a class="link" href="libgnome-gnome-triggers.html#gnome-triggers-vadd-trigger" title="gnome_triggers_vadd_trigger ()">gnome_triggers_vadd_trigger</a>         (<em class="parameter"><code><a class="link" href="libgnome-gnome-triggers.html#GnomeTrigger" title="GnomeTrigger"><span class="type">GnomeTrigger</span></a> *nt</code></em>,
                                                         <em class="parameter"><code><span class="type">char</span> *supinfo[]</code></em>);
<span class="returnvalue">void</span>                <a class="link" href="libgnome-gnome-triggers.html#gnome-triggers-do" title="gnome_triggers_do ()">gnome_triggers_do</a>                   (<em class="parameter"><code>const <span class="type">char</span> *msg</code></em>,
                                                         <em class="parameter"><code>const <span class="type">char</span> *level</code></em>,
                                                         <em class="parameter"><code>...</code></em>);
<span class="returnvalue">void</span>                <a class="link" href="libgnome-gnome-triggers.html#gnome-triggers-vdo" title="gnome_triggers_vdo ()">gnome_triggers_vdo</a>                  (<em class="parameter"><code>const <span class="type">char</span> *msg</code></em>,
                                                         <em class="parameter"><code>const <span class="type">char</span> *level</code></em>,
                                                         <em class="parameter"><code>const <span class="type">char</span> *supinfo[]</code></em>);
</pre>
</div>
<div class="refsect1">
<a name="libgnome-gnome-triggers.description"></a><h2>Description</h2>
<p>
The triggers API provides a way for applications to tell GNOME about
interesting events that then cause something to happen (for example, playing a
sound). An event can either be a function that is called, a sound that is
played or an external command that is run.
</p>
<p>
Each trigger can optionally have a <em class="wordasword">level</em> associated
with it and a <em class="wordasword">section</em>. The
<em class="wordasword">section</em> is a list of strings that help to classify the
event, which imposes a hierarchy on the trigger system. For example, messages
about the hard drive partition /dev/hda1 may come under the section ("system",
"device", "disk", "/dev/hda1"). This means that an application could trigger
all events for the ("system", "device") sections and include those events, or
be more specific and just trigger those for ("system", "device", "disk",
"/dev/hda1").
</p>
<p>
At the present time, triggers are not widely used in GNOME, being mostly used
to play sound events in response to certain actions.
</p>
</div>
<div class="refsect1">
<a name="libgnome-gnome-triggers.details"></a><h2>Details</h2>
<div class="refsect2">
<a name="GnomeTriggerType"></a><h3>enum GnomeTriggerType</h3>
<pre class="programlisting">typedef enum {
	GTRIG_NONE,
	GTRIG_FUNCTION,
	GTRIG_COMMAND,
	GTRIG_MEDIAPLAY
} GnomeTriggerType;
</pre>
<p>
These are the different types of triggers that can be activated by an
application.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><a name="GTRIG-NONE:CAPS"></a><span class="term"><code class="literal">GTRIG_NONE</code></span></p></td>
<td>A null trigger type. Should never be used.
</td>
</tr>
<tr>
<td><p><a name="GTRIG-FUNCTION:CAPS"></a><span class="term"><code class="literal">GTRIG_FUNCTION</code></span></p></td>
<td>The trigger causes a function to be executed.
</td>
</tr>
<tr>
<td><p><a name="GTRIG-COMMAND:CAPS"></a><span class="term"><code class="literal">GTRIG_COMMAND</code></span></p></td>
<td>The trigger causes a command to be executed (using <code class="function">execv()</code>).
</td>
</tr>
<tr>
<td><p><a name="GTRIG-MEDIAPLAY:CAPS"></a><span class="term"><code class="literal">GTRIG_MEDIAPLAY</code></span></p></td>
<td>The trigger causes a sound to be played.
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2">
<a name="GnomeTriggerActionFunction"></a><h3>GnomeTriggerActionFunction ()</h3>
<pre class="programlisting"><span class="returnvalue">void</span>                (*GnomeTriggerActionFunction)       (<em class="parameter"><code><span class="type">char</span> *msg</code></em>,
                                                         <em class="parameter"><code><span class="type">char</span> *level</code></em>,
                                                         <em class="parameter"><code><span class="type">char</span> *supinfo[]</code></em>);</pre>
<p>
The signature of a function that can used as a target for <a class="link" href="libgnome-gnome-triggers.html#GTRIG-FUNCTION:CAPS"><span class="type">GTRIG_FUNCTION</span></a>
types of <a class="link" href="libgnome-gnome-triggers.html#GnomeTrigger" title="GnomeTrigger"><span class="type">GnomeTrigger</span></a> instances.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>msg</code></em> :</span></p></td>
<td>The human-readable message that was passed to <a class="link" href="libgnome-gnome-triggers.html#gnome-triggers-do" title="gnome_triggers_do ()"><code class="function">gnome_triggers_do()</code></a>. May be
<a href="http://library.gnome.org/devel/glib/unstable/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>.</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>level</code></em> :</span></p></td>
<td>The severity level of the event. May be <a href="http://library.gnome.org/devel/glib/unstable/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>.</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>supinfo</code></em> :</span></p></td>
<td>The section in which the event belongs. This is a <a href="http://library.gnome.org/devel/glib/unstable/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> terminated
array.</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2">
<a name="GnomeTrigger"></a><h3>GnomeTrigger</h3>
<pre class="programlisting">typedef struct {
	GnomeTriggerType type;
	union {
		/*
		 * These will be passed the same info as
		 * gnome_triggers_do was given.
		 */
		GnomeTriggerActionFunction function;
		gchar *command;
		struct {
			gchar *file;
			int cache_id;
		} media;
	} u;
        gchar *level;
} GnomeTrigger;
</pre>
<p>
</p>
</div>
<hr>
<div class="refsect2">
<a name="gnome-triggers-add-trigger"></a><h3>gnome_triggers_add_trigger ()</h3>
<pre class="programlisting"><span class="returnvalue">void</span>                gnome_triggers_add_trigger          (<em class="parameter"><code><a class="link" href="libgnome-gnome-triggers.html#GnomeTrigger" title="GnomeTrigger"><span class="type">GnomeTrigger</span></a> *nt</code></em>,
                                                         <em class="parameter"><code>...</code></em>);</pre>
<p>
Adds a new <a class="link" href="libgnome-gnome-triggers.html#GnomeTrigger" title="GnomeTrigger"><span class="type">GnomeTrigger</span></a> instance to the event hierarchy.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>nt</code></em> :</span></p></td>
<td>Information on the new trigger to be added.</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>...</code></em> :</span></p></td>
<td>The section to add the trigger under.</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2">
<a name="gnome-triggers-vadd-trigger"></a><h3>gnome_triggers_vadd_trigger ()</h3>
<pre class="programlisting"><span class="returnvalue">void</span>                gnome_triggers_vadd_trigger         (<em class="parameter"><code><a class="link" href="libgnome-gnome-triggers.html#GnomeTrigger" title="GnomeTrigger"><span class="type">GnomeTrigger</span></a> *nt</code></em>,
                                                         <em class="parameter"><code><span class="type">char</span> *supinfo[]</code></em>);</pre>
<p>
This does the same as <a class="link" href="libgnome-gnome-triggers.html#gnome-triggers-add-trigger" title="gnome_triggers_add_trigger ()"><code class="function">gnome_triggers_add_trigger()</code></a>, except the section is
stored in the <a href="http://library.gnome.org/devel/glib/unstable/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> terminated array <em class="parameter"><code>supinfo</code></em> instead of as a variable
length argument list.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>nt</code></em> :</span></p></td>
<td>Information on the new trigger to be added.</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>supinfo</code></em> :</span></p></td>
<td>The section to add the trigger under.</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2">
<a name="gnome-triggers-do"></a><h3>gnome_triggers_do ()</h3>
<pre class="programlisting"><span class="returnvalue">void</span>                gnome_triggers_do                   (<em class="parameter"><code>const <span class="type">char</span> *msg</code></em>,
                                                         <em class="parameter"><code>const <span class="type">char</span> *level</code></em>,
                                                         <em class="parameter"><code>...</code></em>);</pre>
<p>
Notifies GNOME about an event happening, so that any appropriate handlers
can be run.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>msg</code></em> :</span></p></td>
<td>The human-readable message describing the event (can be <a href="http://library.gnome.org/devel/glib/unstable/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>).</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>level</code></em> :</span></p></td>
<td>The level of severity of the event, or <a href="http://library.gnome.org/devel/glib/unstable/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>.</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>...</code></em> :</span></p></td>
<td>The classification of the event.</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2">
<a name="gnome-triggers-vdo"></a><h3>gnome_triggers_vdo ()</h3>
<pre class="programlisting"><span class="returnvalue">void</span>                gnome_triggers_vdo                  (<em class="parameter"><code>const <span class="type">char</span> *msg</code></em>,
                                                         <em class="parameter"><code>const <span class="type">char</span> *level</code></em>,
                                                         <em class="parameter"><code>const <span class="type">char</span> *supinfo[]</code></em>);</pre>
<p>
Notifies GNOME about an event happening, so that any appropriate handlers
can be run. This does the same as <code class="function">gnome_trigger_do()</code> except that it takes a
<a href="http://library.gnome.org/devel/glib/unstable/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> terminated array instead of a varargs list.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>msg</code></em> :</span></p></td>
<td>The human-readable message describing the event (can be <a href="http://library.gnome.org/devel/glib/unstable/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>).</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>level</code></em> :</span></p></td>
<td>The level of severity of the event, or <a href="http://library.gnome.org/devel/glib/unstable/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>.</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>supinfo</code></em> :</span></p></td>
<td>The classification of the event (<a href="http://library.gnome.org/devel/glib/unstable/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> terminated array).</td>
</tr>
</tbody>
</table></div>
</div>
</div>
</div>
<div class="footer">
<hr>
          Generated by GTK-Doc V1.16</div>
</body>
</html>